GtkContainer: Also copy permanent container's classes on get_path_for_child()
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 19 Nov 2010 18:02:27 +0000 (19:02 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Sat, 4 Dec 2010 14:39:18 +0000 (15:39 +0100)
This makes inheritance work for the simplest cases when style is defined
for classes.

gtk/gtkcontainer.c

index 1be4ab29264245fb35c91284dbcfbabe3e9dc75c..5433766c2542f820f29127c3fabf538a33bdfbcd 100644 (file)
@@ -2215,7 +2215,28 @@ static GtkWidgetPath *
 gtk_container_real_get_path_for_child (GtkContainer *container,
                                        GtkWidget    *child)
 {
-  return gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (container)));
+  GtkStyleContext *context;
+  GtkWidgetPath *path;
+  GList *classes;
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (container));
+  path = gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (container)));
+
+  /* Copy any permanent classes to the path */
+  classes = gtk_style_context_list_classes (context);
+
+  while (classes)
+    {
+      GList *cur;
+
+      cur = classes;
+      classes = classes->next;
+
+      gtk_widget_path_iter_add_class (path, -1, cur->data);
+      g_list_free_1 (cur);
+    }
+
+  return path;
 }
 
 static gboolean